/**
 * Created by chengcong on 2017/12/14.
 */
var url='http://120.27.161.98:6655';
$(function () {
    $('.savemsg').on('click',function () {
        if($('.username').val()==''||$('.userphone').val()==''||$('.usermsg').val()==''){
            alert('请完善必填信息');
        }else {
            var pattern=/(^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$)|(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/;
            if(pattern.test($('.userphone').val())) {
                $.ajax({
                    url: url + '/api/WebPage/AddMess',
                    type: 'POST',
                    data: {
                        MessContent: $('.usermsg').val(),
                        MessPhone: $('.userphone').val(),
                        MessUserName: $('.username').val(),
                        classid: "16"
                    },
                    success: function (data) {
                        console.log(data);
                        if (data.code == 200) {
                            alert('留言成功');
                            $('.usermsg').val('');
                            $('.userphone').val('');
                            $('.username').val('');

                        } else {
                            alert(data.mes);
                        }
                    }
                })
            }else{
                alert('请填写正确的号码！')
            }
        }
    });
})